<template>
  <div class='check-detail'>
    <div class="head box-size">
      <div class="fl">
        <x-circle
          :percent="info.score"
          :stroke-width="6"
          :trail-width="6"
          :stroke-color="['#FF6613', '#FFA200']"
          trail-color="#f2f2f2">
          <span class="content pr" style="color:#36D1DC"><img class="pa" :src="imgs.bac1" alt=""> {{ info.score }}<span style="font-size:12px">分</span> </span>
        </x-circle>
      </div>
      <div class="right-content">
        <p>{{info.title}}</p>
        <p class="content">{{info.content}}查看<span class="color-gold">车友排行</span></p>
      </div>
    </div>

    <div class="body pr">
      <div class="box">
        <div class="box-size">
          <p class="title">
            <span class="width4"></span>
            <span class="width6"></span>
            <span class="width8"></span>
            <span class="width10"></span>
            <span class="title">车检报告</span>
            <span class="width10"></span>
            <span class="width8"></span>
            <span class="width6"></span>
            <span class="width4"></span>
          </p>
          <div class="car-info">
            <p>
              <span>车牌号：<span class="color999">{{info.number}}</span></span>
              <span class="fr">车主：<span class="color999">{{info.carOwner}}</span></span>
            </p>
            <p>当前里程：<span class="color999">{{info.mileage}}公里</span></p>

            <hr class="hr">

            <p>专项目名称：<span class="color999">{{info.itemName}}</span></p>
            <p>检测项目数：<span class="color999">{{info.num}}</span></p>
            <p>检测人：<span class="color999">{{info.checker}}</span></p>
            <p>检测日期：<span class="color999">{{info.date}}</span></p>
            <p>检测评估：</p>

            <ul class="result">
              <li>
                <p>
                  <img class="fl" :src="imgs.logo1" alt=""><span>急需处理</span>
                  <span>{{info.grade.error}}</span>
                </p>
              </li>
              <li>
                <p>
                  <img class="fl" :src="imgs.logo2" alt=""><span>密切关注</span>
                  <span>{{info.grade.warning}}</span>
                </p>
              </li>
              <li>
                <p>
                  <img class="fl" :src="imgs.logo3" alt=""><span>状态良好</span>
                  <span>{{info.grade.good}}</span>
                </p>
              </li>
            </ul>
          </div>

          <div class="detail">
            <p>检测明细：</p>

            <table>
              <tbody>
                <tr>
                  <td>检测项目</td>
                  <td>状态</td>
                  <td>是否维修</td>
                </tr>
                <tr v-for="item in info.detail">
                  <td>{{item.project}}</td>
                  <td>{{item.state}}</td>
                  <td>{{item.repair}}</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
      
    </div>
  </div>
</template>
<script>
import { XCircle } from 'vux'
export default {
  components: {XCircle},
  name: "",
  data() {
    return {
      imgs:{
        bac1:require('../../../assets/img/hpmepage/check/bac.png'),
        bac2:require('../../../assets/img/hpmepage/check/bac2.png'),
        bac3:require('../../../assets/img/hpmepage/check/bac3.png'),

        logo1:require('../../../assets/img/hpmepage/check/1.png'),
        logo2:require('../../../assets/img/hpmepage/check/2.png'),
        logo3:require('../../../assets/img/hpmepage/check/3.png'),

      },
      info:{
        score:80,//车辆打分
        title:"爱车问题未知，请到店检测",
        content:"为保证您的行车安全，爱车需定期做检测，健康值击败门店0%的车友！",
        number:"鄂A23456",
        carOwner:"刘佳1",
        mileage:"10000",//里程数
        itemName:"常规",//项目名称
        num:"10",//项目数
        checker:"老王",//检测人
        date:"2018-5-10",//检测日期
        grade:{
          good:20,
          warning:10,
          error:5
        },
        detail:[
          {
            project:"刹车",
            state:"严重",
            repair:"是"
          },{
            project:"刹车",
            state:"严重",
            repair:"是"
          },{
            project:"刹车",
            state:"严重",
            repair:"是"
          },{
            project:"刹车",
            state:"严重",
            repair:"是"
          },{
            project:"刹车",
            state:"严重",
            repair:"是"
          },{
            project:"刹车",
            state:"严重",
            repair:"是"
          }
        ]
      }
    };
  },
  methods: {
    getList(){
      var params={
        vehicleId:sessionStorage.getItem("detailId")=="暂无"?"":sessionStorage.getItem("detailId"),
        realName:sessionStorage.getItem("userName")
      }
      
      _g.apiPost("trafficReport/getNewest.do",params).then(res=>{
        this.info.score=res.data.maintenance.score||0
        this.info.title=res.data.maintenance.title
        this.info.mileage=res.data.maintenance.currentMileage||0
        this.info.itemName=res.data.maintenance.detectionId
        this.info.num=res.data.maintenance.detectionNum||0
        this.info.checker=res.data.maintenance.detectionPerson||"暂无"
        this.info.date=new Date(res.data.maintenance.detectionTime).toLocaleDateString()
        this.info.grade.error=res.data.maintenance.serious||0
        this.info.grade.warning=res.data.maintenance.slight||0
        this.info.grade.good=res.data.maintenance.good||0

        var goal=[]
        res.data.list.forEach(ele => {
          goal.push({
            project:ele.detectionName,
            state:ele.service_status==1?"良好":ele.service_status==2?"轻微":"严重",
            repair:ele.detection_status==1?"是":"否",
          })
        });
        this.$set(this.info,"detail",goal)
      }).then(()=>{
        var strObj=sessionStorage.getItem("carInfo")=="undefined"?"{}":sessionStorage.getItem("carInfo")
        // console.log(strObj)
        var info=JSON.parse(strObj)
        this.info.number=info.plateNum||"暂无"
        this.$set(this.info,"carOwner",sessionStorage.getItem("userName")||"暂无")
        
      })
    }
  },
  created() {
    this.getList()
  }
};
</script>
<style lang="scss" scoped>
.check-detail {
  height: 100%;
  background-color: #f2f2f2;
  overflow-y: auto;

  .head,.body{
    min-height: 115px;
    padding: 15px;
    background-color: #fff;
    margin-bottom: 5px;
  }
  .fl{
    width: 85px;
    height: 85px;

    .content{
      display: inline-block;
      width: 85%;
      height: 85%;
      border-radius: 50%;
      margin-top: 7.5%;
      line-height: 70px;
      font-size: 24px;
      color: #fff!important;

      img{
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: -1;
      }
    }
  }

  .right-content{
    margin-left: 100px;
    font-size: 14px;
    color: #333;
    padding: 15px 0;

    .content{
      font-size: 12px;
      color: #666;
      margin-top: 10px;

      .color-gold{
        text-decoration: underline;
      }
    }
  }

  .body{
    // min-height: 750px;
    margin-bottom: 0;
    
    .box{
      background: url(../../../assets/img/hpmepage/check/bac2.png);
      padding: 10px 0;
    }

    div.box-size{
      margin: 10px;
      height: calc(100% - 30px);
      background-color: #fff9dd;
      border-radius: 10px;
      
      padding: 30px 10px;

      >p.title{
        text-align: center;
        margin-bottom: 10px;

        span{
          display: inline-block;
          background-color: #F4B40A;
          border-radius: 50%;
          vertical-align: middle;
        }
        .title{
          border-radius: 0;
          color: #6F3400;
          font-size: 18px;
          background-color: transparent;
        }
      }
      div.car-info{
        font-size: 14px;
        color: #333;

        p{
          height: 25px;
          line-height: 25px;
        }

        .hr{
          border: 1px dashed #854200;
          opacity: 0.14;
        }

        ul.result{
          display: flex;
          background-color: #FFEBC8;
          border-radius: 2px;
          box-sizing: border-box;
          height: 63px;
          padding: 8px 0;

          li{
            width: calc(100% / 3);
            padding: 0 5px;
            border-left: 1px solid #C2AB84;

            img{
              width: 15px;
              height: 15px;
              transform: translateY(5px);
              margin-right: 5px;
            }

            >p{
              
              span:nth-of-type(2){
                display: block;
                text-align: center;
              }
            }
          }

          li:nth-child(1){
            border: none;
          }
        }
      }
    }

    div.detail{
      margin-top: 10px;

      p{
        font-size: 14px;
        color: #333;
      }

      table{
        width: 100%;
        margin-top: 5px;

        tr{
          display: flex;
          height: 40px;
          line-height: 40px;
          background-color: #FFEBC8;
        }
        tr:nth-child(2n+1){
          background-color: #EC971C
        }
        tr:nth-child(1) td{
          font-size: 14px;
        }
        td{
          width: 0;
          flex-grow: 1;
          text-align: center;
          font-size: 12px;
        }
      }
    }
  }
}

.width4{
  width: 4px;
  height: 4px;
}
.width6{
  width: 6px;
  height: 6px;
}
.width8{
  width: 8px;
  height: 8px;
}
.width10{
  width: 10px;
  height: 10px;
}
</style>